package com.perceptivesoftware.licensing.client.dto;

import com.extjs.gxt.ui.client.data.BaseModel;
import com.google.gwt.user.client.ui.HTML;
import com.perceptivesoftware.licensing.client.common.util.ClientConstants;

public class VideoModel extends BaseModel
{
	private static final long serialVersionUID = 1L;
	private VideoDTO dto;

	public VideoModel(VideoDTO dto)
	{
		this.dto = dto;
		set("thumb", getThumbnail());
		set("title", dto.getTitle());
		set("createdAt", dto.getCreatedAt());
		set("contributor", dto.getContributor());
	}

	public HTML getThumbnail()
	{
		String html = "<img src=\"" + ClientConstants.TWISTAGE_BASE_URL + "/videos/" + dto.getVideoId() + "/screenshots/120w120h.png\"/>";
		/*TODO NOTE ON THUMBNAIL URL
		 * 
		 * Thumbnail url is dynamic. The url should be <TwistageApiBase>/videos/<VideoID>/screenshots/<width>w<height>h.<extension>
		 * 
		 * - Must specify one of either width or height, both are not required but are an option.
		 * - Extension is required, twistage will auto convert it to the type passed in if it doesn't exist already in that format.
		 * 
		 * EXAMPLE : - For a 100x100 png you would use 100w100h.png.
		 * 			 - For a 100 width jpg you would use 100w.jpg
		 * 			 - For a 100 height png you would use 100h.png.
		 */
		

		return new HTML(html);
	}

	public VideoDTO getDto()
	{
		return dto;
	}
}